// 创建用于存储的模块
import { asyncRoutes, constantRoutes } from '@/router/index'
const state = {
  routers: []
}

const mutations = {
  stetRouters(state, routers) {
    state.routers = [...constantRoutes, ...routers]
  }
}
const actions = {
  filterRouters(context, menus) {
    const routers = asyncRoutes.filter(item => {
      return menus.includes(item.code)
    })
    context.commit('stetRouters', routers)
    return routers
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
